var Api = require('../../utils/api.js');
var app = getApp();

Page({
  data: {
    is_onload:true,
    conference_id: "",
    exhibition: [
      {
        'exhibition_name':'微点云助教',
        'exhibition_cover': 'http://i01.wedots.cn/10011/2018/11/02JVRyCtSWU.png?imageMogr2/thumbnail/400x400!/quality/75/format/png',
        'exhibition_position': 'A区A11',
      },
    ]
  },
  onLoad: function (options) {
    if (options.conference_id) {
      this.setData({
        conference_id: options.conference_id
      });
      this.initConference(options.conference_id);
    } else {
      this.initConference();
    }

  },
  initConference: function (conference_id = "") {
    var that = this;
    wx.showToast({
      title: '加载中...',
      icon: 'loading',
      duration: 10000
    });
    that.loadAgenda({ "conference_id": conference_id });
  },
  loadAgenda: function (o = {}) {
    var that = this;
    wx.request({
      url: Api.loadExhibition(o),
      header: {
        'content-type': 'application/json'
      }, // 设置请求的 header
      success: function (res) {
        if (res.data.exhibition && res.data.exhibition.length){
          that.setData({ 
            exhibition: res.data.exhibition
          });
        }
        wx.hideToast();
        wx.stopPullDownRefresh({
          complete: function (res) {
            console.log(res, new Date())
          }
        });
      },
      fail: function () {
        // fail
        // wx.hideToast();
      },
      complete: function () {
        // complete
      }
    });
  },
  onReady: function () {
    // 页面渲染完成
  },
  onShow: function () {
    // 页面显示
  },
  onHide: function () {
    // 页面隐藏
  },
  onUnload: function () {
    // 页面关闭
  },
  onPullDownRefresh: function () {
    this.initConference();
  },
  onShareAppMessage: function () {
    var that = this;
    return {
      title: '展商信息',
      path: 'page/exhibition/index?conference_id=' + this.data.conference_id,
      success: function (res) {

      },
      fail: function (res) {
        // 分享失败
      }
    }
  }
});